package com.simit.service.impl;

import com.simit.mapper.UserMapper;
import com.simit.pojo.User;
import com.simit.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    @Qualifier("userMapper")
    private UserMapper mapper;

    @Override
    public List<User> selectAll() {
        return mapper.selectAll();
    }

    @Override
    public User select(String username, String password) {
        return mapper.select(username, password);
    }

    @Override
    public User selectByUsername(String username) {
        return mapper.selectByUsername(username);
    }

    @Override
    public void add(User user) {
        mapper.add(user);
    }

    @Override
    public void addMoney(String username, int moneyAdd) {
        mapper.addMoney(username, moneyAdd);
    }

    @Override
    public void subtractMoney(String username, int moneySubtract) {
        mapper.subtractMoney(username, moneySubtract);
    }

    @Override
    public void transfer(String usernameOut, String usernameIn, int money) {
        mapper.subtractMoney(usernameOut, money);
        mapper.addMoney(usernameIn, money);
    }
}
